// 导入二次封装axios
import http from '@/core/request/request.ts'

// 统一管理接口
enum API {
  LIST_DICT_TYPE = '/adminapi/sysDictType/listDictType',
  LIST_PAGE = '/adminapi/sysDictData/listPage',
  GET_BY_ID = '/adminapi/sysDictData/getById',
  UPDATE = '/adminapi/sysDictData/update',
  ADD = '/adminapi/sysDictData/add',
  DELETE = '/adminapi/sysDictData/deleteById',
  BATCH_DELETE = '/adminapi/sysDictData/batchDelete',
  UPDATE_STATE = '/adminapi/sysDictData/updateStatus',
  LIST_DATA_BY_TYPE = '/adminapi/sysDictData/listDataByType',
}
// 暴露请求函数
// 条件下拉框
export const listDictType = () => {
  return http.get(API.LIST_DICT_TYPE)
}
// 多条件分页查询数据
export const listPage = (params: any) => {
  return http.get(API.LIST_PAGE, params)
}

// 根据ID进行查询
export const getById = (id: any) => {
  return http.get(API.GET_BY_ID + '/' + id)
}

// 根据ID进行修改
export const update = (data: any) => {
  return http.post(API.UPDATE, data)
}

// 添加
export const add = (data: any) => {
  return http.post(API.ADD, data)
}

// 删除
export const deleteById = (id: any) => {
  return http.post(API.DELETE + '/' + id) // 第一种传参方式
}

// 批量删除
export const batchDelete = (ids: any) => {
  return http.post(API.BATCH_DELETE, ids) // 第一种传参方式
}

// 修改状态
export const updateStatus = (id: any, status: any) => {
  return http.post(API.UPDATE_STATE + '/' + id + '/' + status) // 第一种传参方式
}

// 根据字典类型查询数据
export const listDataByType = (dictType: any) => {
  return http.get(API.LIST_DATA_BY_TYPE + '/' + dictType) // 第一种传参方式
}
